function KKB.Panel_Toolguns( Panel )
	Panel_Toolguns = Panel
	Panel_Toolguns:SetSize(100, 400)
	Panel_Toolguns:Clear(true)
	Panel_Toolguns.contents = vgui.Create("DListLayout")
	Panel_Toolguns.contents:Clear()
	
	KKB.Toolguns_GroupList = vgui.Create( "DListView" )
	KKB.Toolguns_GroupList:AddColumn( "User Group" )
	KKB.Toolguns_GroupList:SetTall( 150 )
	KKB.Toolguns_GroupList:SetMultiSelect( true )
	function KKB.Toolguns_Reload_GroupList()
		KKB.Toolguns_GroupList:Clear()
		for k,_ in pairs(KKB.UserGroups) do
			KKB.Toolguns_GroupList:AddLine(k)
		end
	end
	KKB.Toolguns_Reload_GroupList()
	Panel_Toolguns:AddPanel(KKB.Toolguns_GroupList)
	
	local AddGroupButton = vgui.Create( "DButton" )
	AddGroupButton:SetText( "Add Group(s) To Selected Toolgun" )
	AddGroupButton.DoClick = function( button )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			local SelectedLines = KKB.Toolguns_GroupList:GetSelected()
			if ( #SelectedLines > 0 ) then
				local Toolgun = TreeItem:GetText()
				local Groups = {}
				for _,v in pairs(SelectedLines) do
					local Group = v.Columns[1]:GetValue()
					if ( KKB.ToolgunRestrictions[Toolgun] == nil or not table.HasValue(KKB.ToolgunRestrictions[Toolgun].Groups, Group) ) then
						table.insert(Groups, Group)
					end
				end
				if ( #Groups > 0 ) then
					net.Start( "KKB_Tool_Add" )
					net.WriteTable( Groups )
					net.WriteString( Toolgun )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(AddGroupButton)
	
	Panel_Toolguns.ToolTree = vgui.Create( "DTree" )
	Panel_Toolguns.ToolTree:SetPadding( 5 )
	Panel_Toolguns.ToolTree:SetTall( 400 )
	local ToolName = nil
	for _,v in pairs(spawnmenu.GetTools()) do
		if ( v.Name == "AAAAAAA_Main" or v.Name == "Wire" or v.Name == "Stargate" ) then
			local Name = v.Name
			if ( Name == "AAAAAAA_Main" ) then Name = "Tools" end
			local Category = Panel_Toolguns.ToolTree:AddNode( Name )
			Category.DoClick = function( Item )
				Item:SetSelected( false )
			end
			for _,y in pairs(v.Items) do
				local Group = Category:AddNode( y.ItemName )
				Group.DoClick = function( Item )
					Item:SetSelected( false )
				end
				local Amt = #y
				while Amt > 0 do
					local Tool = Group:AddNode( y[Amt].ItemName )
					Tool.DoClick = function( Node )
						Panel_Toolguns.AllowedGroupList:Clear()
						ToolName = Node:GetText()
						if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
							Panel_Toolguns.WorldCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.World)
							Panel_Toolguns.WorldPropsCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.WorldProps)
							Panel_Toolguns.VehiclesCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.Vehicles)
							Panel_Toolguns.WeaponsCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.Weapons)
							Panel_Toolguns.NPCsCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.NPCs)
							Panel_Toolguns.SentsCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.Sents)
							Panel_Toolguns.PlayersCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.Players)
							Panel_Toolguns.OtherCheck:SetValue(KKB.ToolgunRestrictions[ToolName].Options.Other)
							for _,v in pairs(KKB.ToolgunRestrictions[ToolName].Groups) do
								Panel_Toolguns.AllowedGroupList:AddLine(v)
							end
						end
					end
					Amt = Amt - 1
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.ToolTree)
	
	Panel_Toolguns.AllowedGroupList = vgui.Create( "DListView" )
	Panel_Toolguns.AllowedGroupList:AddColumn( "Allowed User Group" )
	Panel_Toolguns.AllowedGroupList:SetTall( 150 )
	Panel_Toolguns.AllowedGroupList:SetMultiSelect( true )
	function KKB.Toolguns_Reload_AllowedGroups()
		Panel_Toolguns.AllowedGroupList:Clear()
		if ( ToolName != nil ) then
			for _,v in pairs(KKB.ToolgunRestrictions[ToolName].Groups) do
				Panel_Toolguns.AllowedGroupList:AddLine(v)
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.AllowedGroupList)
	
	local RemoveGroupButton = vgui.Create( "DButton" )
	RemoveGroupButton:SetText( "Remove Group(s) From Selected Toolgun" )
	RemoveGroupButton.DoClick = function( button )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			local SelectedLines = KKB.Toolguns_GroupList:GetSelected()
			if ( #SelectedLines > 0 ) then
				local Groups = {}
				for _,v in pairs(SelectedLines) do
					local Group = v.Columns[1]:GetValue()
					if ( KKB.ToolgunRestrictions[ToolName] != nil and table.HasValue(KKB.ToolgunRestrictions[ToolName].Groups, Group) ) then
						table.insert(Groups, Group)
					end
				end
				if ( #Groups > 0 ) then
					net.Start( "KKB_Tool_Delete" )
					net.WriteTable( Groups )
					net.WriteString( ToolName )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(RemoveGroupButton)
	
	Panel_Toolguns.BlacklistCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.BlacklistCheck:SetText("Blacklist?")
	Panel_Toolguns.BlacklistCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.BlacklistCheck:SetValue(KKB.Settings.Toolguns.Blacklist)
	Panel_Toolguns.BlacklistCheck.OnChange = function( _, fVal )
		if ( KKB.Settings.Toolguns.Blacklist != fVal ) then
			net.Start( "KKB_Settings_Update" )
			net.WriteString( "Toolguns" )
			net.WriteString( "Blacklist" )
			net.WriteUInt( KKB.BoolToInt(fVal), 32 )
			net.SendToServer()
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.BlacklistCheck)
	Panel_Toolguns:AddControl("Label", {Text = ""})
	
	Panel_Toolguns.WorldCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.WorldCheck:SetText("On World")
	Panel_Toolguns.WorldCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.WorldCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.World != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "World" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddControl("Label", {Text = "Determines What This Toolgun Can Touch"})
	Panel_Toolguns:AddPanel(Panel_Toolguns.WorldCheck)
	
	Panel_Toolguns.WorldPropsCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.WorldPropsCheck:SetText("On World Props")
	Panel_Toolguns.WorldPropsCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.WorldPropsCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.World != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "WorldProps" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.WorldPropsCheck)
	
	Panel_Toolguns.VehiclesCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.VehiclesCheck:SetText("On Vehicles")
	Panel_Toolguns.VehiclesCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.VehiclesCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.Vehicles != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "Vehicles" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.VehiclesCheck)
	
	Panel_Toolguns.WeaponsCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.WeaponsCheck:SetText("On Weapons")
	Panel_Toolguns.WeaponsCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.WeaponsCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.Weapons != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "Weapons" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.WeaponsCheck)
	
	Panel_Toolguns.NPCsCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.NPCsCheck:SetText("On NPCs")
	Panel_Toolguns.NPCsCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.NPCsCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.NPCs != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "NPCs" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.NPCsCheck)
	
	Panel_Toolguns.SentsCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.SentsCheck:SetText("On Sents")
	Panel_Toolguns.SentsCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.SentsCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] == nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.Sents != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "Sents" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.SentsCheck)
	
	Panel_Toolguns.PlayersCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.PlayersCheck:SetText("On Players")
	Panel_Toolguns.PlayersCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.PlayersCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.Players != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "Players" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.PlayersCheck)
	
	Panel_Toolguns.OtherCheck = vgui.Create("DCheckBoxLabel")
	Panel_Toolguns.OtherCheck:SetText("On Other")
	Panel_Toolguns.OtherCheck:SetTextColor( Color(0, 0, 0, 255) )
	Panel_Toolguns.OtherCheck.OnChange = function( _, fVal )
		local TreeItem = Panel_Toolguns.ToolTree:GetSelectedItem()
		if ( TreeItem != nil ) then
			if ( KKB.ToolgunRestrictions[ToolName] != nil ) then
				if ( KKB.ToolgunRestrictions[ToolName].Options.Other != fVal ) then
					net.Start( "KKB_Tool_Update" )
					net.WriteString( ToolName )
					net.WriteString( "Other" )
					net.WriteUInt( KKB.BoolToInt(fVal), 32 )
					net.SendToServer()
				end
			end
		end
	end
	Panel_Toolguns:AddPanel(Panel_Toolguns.OtherCheck)
end